<?php

use Illuminate\Http\Request;
use Illuminate\Routing\Router;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/


Route::get('/user', function (Request $request) {
    return $request->user();

})->middleware('auth:api');

Route::group(['namespace'=>'Api'],function(){
    Route::any('/testing/user/init','UserController@init')->name('api.user.init');
    Route::any('/testing/user/check/{uid}','UserController@checkUserInfo')->name('api.user.init');
    Route::any('/testing/user/auth/{developerCode}/{callback}','UserController@auth')->name('api.user.auth');
    Route::post('/url/encode','ApiController@encodeUrl')->name('api.url.encode');
    //茄子帐号中心授权后的回调url
    Route::get('/testing/user/qz/callback/{thirdPartyCbUrlId}/{uid}/{authorize?}','UserController@qieziAccountCallback')->name('api.user.qz.callback');
    //用户绑定渠道
    Route::post('/testing/user/bind/channel','UserController@bindChannel')->name('api.user.bind.channel');
    //用户提交信息手机号和姓名、微信号
    Route::post('/testing/user/submit/info','UserController@submitInfo')->name('api.user.submit.info');
    //查看用户的详细信息
    Route::get('/testing/user/user/info/{uid}','UserController@getUserInfo')->name('api.user.get.user.info');
    //通过减脂平台验证手机号
    Route::post('/testing/user/check/phone/order','UserController@checkPhoneByOrder')->name('api.user.check.phone.order');
    //根据手机号获取用户信息
    Route::get('/user/info/phone','UserController@getUserInfoByPhone')->name('api.user.info.phone');
    Route::get('/testing/cate/list','ApiController@cateList')->name('api.testing.cate.list');
    Route::get('/testing/list','ApiController@testingList')->name('api.testing.list');
    Route::get('/testing/{type}/{id}/{uid}','ApiController@testingDetail')->name('api.testing.detail');
    Route::post('/testing/submit','ApiController@submitTesting')->name('api.testing.submit');
    Route::post('/wx/share/option','ThirdPartyController@getWxShareOption')->name('api.wx.share');
    Route::post('/wx/share/option/platform','ThirdPartyController@getPlatformWxShare')->name('api.wx.share.platform');
    //统计定时插入数据库
    Route::get('/testing/timingTask','ApiController@timingToMysql');
    //第三方平台发送模板消息转发
    Route::get('/testing/wechat/sendtpl/{uid}/{appid}/{tplid}','WxComponentController@sendTemplate')->name('api.testing.sendTemplate');
    //减脂平台打卡评价
    Route::post('/testing/wechat/admin/evaluate','WxComponentController@evaluate')->name('api.testing.evaluate');
    //饮食、运动打卡地址回调url
    Route::get('/testing/wechat/cricle/callback/{tplid}/{appid}','WxComponentController@criclePath')->name('api.testing.callback');
    //减脂平台存储用户发送模板消息记录
    Route::post('/testing/wechat/admin/startsendtpl','WxComponentController@StartSendTplUser')->name('api.admin.startsendtpl');
    //减脂平台更新用户发送模板消息记录并结束发送模板消息
    Route::post('/testing/wechat/admin/endsendtpl','WxComponentController@EndSendTplUser')->name('api.admin.endsendtpl');
    //减脂平台定时发送模板消息
    //测试环境易买车 http://cptest3.qiezilife.com/api/testing/wechat/admin/timingsendtpl/wx350bc3f5cbc9191a/21/OPENTM406106195
    Route::get('/testing/wechat/admin/timingsendtpl/{appid}/{tid}/{tplid}','WxComponentController@timingSendTpl')->name('api.admin.timingsendtpl');
    //根据手机号获取形体评估的结果信息
    Route::get('/dimension/physique/result/{tid}/{phone}','RpcController@physiqueResultPhone')->name('api.dimension.physique.result.phone');
});

/**
* 新健保路由
*/
Route::group(['namespace'=>'Api'],function(){
    Route::post('/xjb/health/submit','HealthController@submitTesting')->name('health.testing.submit');
    Route::post('/xjb/health/resubmit','HealthController@reSubmit')->name('health.testing.reSubmit');
    Route::get('/xjb/health/list','HealthController@testingList')->name('health.testing.list');
    Route::get('/xjb/health/{type}/{tid}/{uid}','HealthController@testingDetail')->name('health.testing.list');
});

/**
 * 新健保v2.0路由
 */
Route::group(['namespace'=>'Api'],function() {
    Route::post('/xjb/cancer/submit', 'CancerController@submit')->name('cancer.testing.submit');
    //Route::post('/xjb/health/resubmit','HealthController@reSubmit')->name('health.testing.reSubmit');
    Route::get('/xjb/cancer/item', 'CancerController@testingitem')->name('cancer.testing.list.item');
    Route::get('/xjb/cancer/all/{uid}', 'CancerController@testingAll')->name('cancer.testing.result.all');
    Route::get('/xjb/cancer/single/{tid}/{uid}', 'CancerController@testingSingle')->name('cancer.testing.result.single');
});


/**
* 太保接口
*/
Route::group(['namespace'=>'Api'],function(){
    Route::post('/tb/authorization','TbController@auth')->name('tb.auth');
    Route::get('/tb/testing/{tid}/{uid}/{enterpriseId}','TbController@result')->name('tb.result');
    Route::get('/tb/testing/count/{tid}/{appid}/{enterpriseId}','TbController@countPerson')->name('tb.count.by.id');
    Route::get('/tb/testing/data/alynasis','TbController@alynasis')->name('tb.count.alynasis');
});


/**
* 开发者开发接口
*/
Route::group(['namespace'=>'Api'],function(){
    Route::get('/developer/info/by/code/{code}','DeveloperController@getDeveloperInfoByUnionCode')->name('developer.info.by.code');
    Route::get('/developer/info/by/appid/{appid}','DeveloperController@getDeveloperInfoByAppid')->name('developer.info.by.appid');
});


/**
 * barCode接口
 */
Route::group(['namespace'=>'Api'],function(){

    Route::get('/barCode/{barCode}','BarCodeController@auth');

});

/**开放给系统内部的接口的接口*/
Route::group(['namespace'=>'Api'],function(){
    Route::get('/user/recipe/tag/{tid}/{uid}','RpcController@getUserRecipeTag')->name('user.recipe.tag');

    Route::get('/customer/questionnair/add','RpcController@addCustomerQuestionnair')->name('customer.questionnair.add');
    //新增渠道保存或修改
    Route::get('/channel/add', 'RpcController@channelAdd')->name('channel.add');
    //修改用户的答题记录
    Route::get('/fix/user/record', 'RpcController@fixUserRecord')->name('fix.user.record');
    //获取测评营销面板的信息
    Route::get('/get/testing/base/info', 'RpcController@getTestingBaseInfo')->name('testing.base.info');
    //获取测评的答题信息
    Route::get('/get/order/testing/info', 'RpcController@getOrderTestingInfo')->name('order.testing.info');
    //获取测评订单的 PD 值
    Route::get('/get/testing/pd/info', 'RpcController@getOrderPDInfo')->name('order.pd.info');
});

/**
 * testing standard interface
 */
Route::group(['namespace'=>'Api'],function(){

    Route::get('/developer/authirization','StandardApiController@auth');
    Route::get('/partner/testing/list','StandardApiController@getTestingList');
    /**单个测评的链接接口*/
    Route::get('/testing/single','StandardApiController@accessSingleTesting');
    /**单个测评下的所有答题记录*/
    Route::get('/testing/user/record/list/anylasis','StandardApiController@getUserTestingRecordListAnylasis');
    /**用户记录的答案接口*/
    Route::get('/testing/user/answer','StandardApiController@getTestingAnswer');
    /**加密数字接口*/
    Route::get('/testing/number/encode','StandardApiController@encodeNumber');
    /**用户最新的答题记录分析*/
    Route::get('/testing/user/anylasis','StandardApiController@getUserRecord');
    // Determine whether the user has done the test
    Route::get('/testing/user/judge','StandardApiController@judgeUserRecord');

});

/**
 * 减脂后台相关模块调用接口
 */
Route::group(['namespace'=>'Api'],function(){
    //Route::get('/jz/flow/record','JzApiController@getRecord')->name('jz.flow.record');
    //引流模块
     Route::get('/jz/flow/update','JzApiController@updateRecord')->name('jz.flow.update');
    //邀请码模块
    Route::get('/jz/invitation/update','JzApiController@invitation')->name('jz.flow.update');
    //
    Route::get('/jz/sync/record/info','RpcController@syncQnRecordInfo')->name('jz.sync.record.info');
    //同步减脂平台的复购订单的测评信息
    Route::get('/jz/sync/purchase/order/qn/info','RpcController@syncJzPurchaseOrderQnInfo')->name('jz.sync.purchase.order.qn.info');
    Route::get('/jz/sync/free/to/purchase','RpcController@syncFreeOrderTestingToPurchase')->name('jz.sync.free.order.testing.to.purchase');
    //获取减脂平台订单对应的用户的测评列表
    Route::get('/jz/get/order/qn/list','RpcController@getJzOrderQnRecord')->name('jz.order.qn.list');
    //获取代谢用户订单详情填充至测评列表中
    Route::get('/jz/meta/info/list','JzApiController@getJzMetaInfo')->name('jz.,meta.info');
    //获取减脂平台订单对应的用户的测评列表
    Route::get('/jz/check/free/order/qn','RpcController@checkFreeOrderQn')->name('jz.freeeorder.qn.check');
    //获取减脂平台订单对应的用户的测评列表
    Route::get('/sync/virtual/order/qn','RpcController@syncVirtualOrderRecordInfo')->name('jz.virtual.order.qn.sync');
    //获取减脂平台订单对应的用户的测评列表
    Route::get('/five/dimension/qn/list','RpcController@getFiveDimensionQnList')->name('qn.five.dimension.list');
});

/**
 * 五维健康测评相关模块调用接口
 */
Route::group([ 'namespace' => 'Api' ], function() {
    //获取部分测评信息接口
    Route::get('/five/dimension/assessment/info/{type}/{tid}/{uid}','DimensionApiController@fiveDimensionAssessment')->name('five.dimension.assessment.info');
    //提交测评信息接口
    Route::post('/five/dimension/submit','DimensionApiController@submitFiveDimension')->name('five.dimensional.submit');
    //获取五维测评的结果信息
    Route::get('/five/dimension/result/{tid}/{uid}','DimensionApiController@fiveDimensionResult')->name('five.dimensional.result');
    Route::get('/five/dimension/config/{type}/{config}','DimensionApiController@getConfig')->name('five.dimensional.get.config');
    //获取营养师列表信息
    Route::get('/nutrition/list','DimensionApiController@nutritionList')->name('nutrition.list');
    Route::get('/nutrition/detail/info/{nutritionId}','DimensionApiController@getNutritionInfo')->name('nutrition.detail.info');
});

/**
 * 维度测评相关模块
 */
Route::group([ 'namespace' => 'Api' ], function() {
    //获取维度测评信息接口
    Route::get('/dimension/question/info/{type}/{tid}/{uid}','DimensionApiController@dimensionQuestionInfo')->name('dimension.question.info');
    //提交维度测评信息接口
    Route::post('/dimension/submit','DimensionApiController@dimensionSubmit')->name('five.dimensional.submit');
    //获取维度测评的结果信息
    Route::get('/dimension/result/{tid}/{uid}','DimensionApiController@dimensionResult')->name('five.dimensional.result');
    //获取测评的结果页信息
    Route::get('/dimension/result/{func}/{tid}/{uid}','DimensionApiController@typeDimensionResult')->name('five.dimensional.result.type');
});




